<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>es6-2演示</title>
</head>
<body>
<h2>es6演示</h2>
<script>
  function sum(x, y, z) {
    let total = 0;
    if (x) total += x;
    if (y) total += y;
    if (z) total += z;

    console.log(`total:${total}`);
  }

  sum(5, '', 8);

  function sum2(...m) {
    let total = 0;
    for (var i of m) {
      total += i;
    }
    console.log(`total:${total}`);
  }

  sum2(4, 6, 8, 2);

  let sum3 = (...m) => {
    let total = 0;
    for (var i of m) {
      total += i;
    }
    console.log(`total:${total}`);
  };
  sum3(4, 6, 8, 2);

  var [x, y] = [4, 8];
  console.log(...[4, 8]);

  let arr1 = [1, 3];
  let arr2 = [4, 8];
  console.log("concat:" + arr1.concat(arr2));

  //  [...arr1,...arr2]
  //
  //  var [x,y] = [4,8];
  var [x, ...y] = [4, 8, 10, 30];

  let [a, b, c] = "ES6";

  let xy = [...'es6'];
</script>
</body>
</html>
